<?php
use com\mostka\serializer\BadPrimitiveTypeException;
use com\mostka\serializer\Serializer;

/**
 * Created by PhpStorm.
 * User: Jozef Môstka
 * Date: 5/25/14
 * Time: 7:23 PM
 */

class TestObject2Generated  extends TestObject2{

    /**
     * @param $___serializer Serializer
     * @param TestObject2[] $___TestObject2
     */
    public static function ___serializeArr($___serializer, $___TestObject2){
        $___serializer->writeByte(Serializer::OBJECT_ARR);
        if ($___TestObject2==null){
            $___serializer->writeInteger(-1);
            return;
        }
        $___serializer->writeInteger(count($___TestObject2));
        foreach($___TestObject2 as $t){
            /** @var TestObject2 $t */
            self::___serialize($___serializer,$t);
        }
    }

    /**
     * @param Serializer $___serializer
     * @param TestObject2 $___TestObject2
     */
    public static function ___serialize( $___serializer,  $___TestObject2){
        $___serializer->writeByte(Serializer::OBJECT);

        $___serializer->writeBoolean($___TestObject2==null);
        if ($___TestObject2==null){
            return;
        }

        $___serializer->writeStringArr($___TestObject2->aaa);
        $___serializer->writeIntegerArr($___TestObject2->bbb);
        $___serializer->writeDoubleArr($___TestObject2->ccc);
        $___serializer->writeCharArr($___TestObject2->ddd);
        $___serializer->writeLongArr($___TestObject2->eee);
        $___serializer->writeByteArr($___TestObject2->fff);
        $___serializer->writeShortArr($___TestObject2->ggg);
        $___serializer->writeBooleanArr($___TestObject2->hhh);
    }

    /**
     * @param Serializer $___serializer
     * @return null|\TestObject2[]
     * @throws BadPrimitiveTypeException
     */
    public static function ___deserialize($___serializer){
        $___serializer->checkType(Serializer::OBJECT);
        if ($___serializer->readBoolean()){
            return null;
        }
        $___TestObject2 = new TestObject2();
        $___TestObject2->aaa = $___serializer->readStringArr();
        $___TestObject2->bbb = $___serializer->readIntegerArr();
        $___TestObject2->ccc = $___serializer->readDoubleArr();
        $___TestObject2->ddd = $___serializer->readCharArr();
        $___TestObject2->eee = $___serializer->readLongArr();
        $___TestObject2->fff = $___serializer->readByteArray();
        $___TestObject2->ggg = $___serializer->readShortArr();
        $___TestObject2->hhh = $___serializer->readBooleanArr();

        return $___TestObject2;
    }

    /**
     * @param Serializer $___serializer
     * @return TestObject2[]|null
     * @throws BadPrimitiveTypeException
     */
    public static function ___deserializeArr($___serializer){
        $___serializer->checkType(Serializer::OBJECT_ARR);
        $___len = $___serializer->readInteger();
        if ($___len==-1){
            return null;
        }
        /** @var TestObject2[] $___len */
        $___ret = array();
        for($___i=0;$___i<$___len;$___i++){
            $___ret[$___i]=TestObject2Generated::___deserialize($___serializer);
        }
        return $___ret;
    }
} 